package com.echo.fm.testip;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.echo.util.JSONResult;
import com.echo.util.ResultUtils;
import com.echo.util.impl.CheckIp;
import com.echo.util.impl.ValidateUtils;

@Controller
public class ITestIpContotroller {
	@Autowired
	@Qualifier("checkIp")
	CheckIp checkIp;

	@RequestMapping(value = "/web/test/ip")
	@ResponseBody
	public Object testIp(HttpServletRequest request, HttpServletResponse response) {
		//String httpUrl = "http://apis.baidu.com/showapi_open_bus/ip/ip";
		String ip = request.getParameter("ip");
		if (ValidateUtils.isNotEmpty(ip)) {
			checkIp.request(ip);
		}
		
		String checkIps = checkIp.request(ip);
		JSONResult jsonResult = ResultUtils.instJSONResult(ResultUtils.WEB_SUCCESS_CODE);
		jsonResult.setData(checkIps);
		System.out.println(jsonResult);
		return jsonResult;
	}

}
